//
//  GameAppController.m
//  unity-plugin
//
//  Created by 黄松炎 on 18/9/11.
//

#import "GameAppController.h"

@interface GameAppController ()

@end

IMPL_APP_CONTROLLER_SUBCLASS (GameAppController)

@implementation GameAppController



- (void)startUnity:(UIApplication*)application
{
    NSLog(@"startUnity");
    [NSThread sleepForTimeInterval:2];
    return [super startUnity:application];
}


- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    NSLog(@"didFinishLaunchingWithOptions");
    //sleep(2);
    //[NSThread sleepForTimeInterval:2];
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}


/**
 * 登录接口
 */
extern "C" void login(){
    NSLog(@"login");

    [[GameSDKApi shareInstance] login];
}




/**
 * 设置登录监听
 */
extern "C" void setOnLoginListener(const char *gameObject){
    NSLog(@"setOnLoginListener");
    [[GameSDKApi shareInstance] setOnLoginListener:[NSString stringWithUTF8String:gameObject]];
}

/**
 * 退出登录
 */
extern "C" void logout(){
    NSLog(@"logout");
    [[GameSDKApi shareInstance] logout];
}

/**
 * 支付
 */
extern "C" void pay(const char *payJson,const char *gameObject){
    //调用sdk检查支付逻辑，回调通过gameObject发送
    NSLog(@"pay:%@",[NSString stringWithUTF8String:payJson]);
    [[GameSDKApi shareInstance]pay:[NSString stringWithUTF8String:payJson] gameObject:[NSString stringWithUTF8String:gameObject]];
}

/**
 * 检查支付
 */
extern "C" void checkPay(const char *gameObject){
    //调用sdk检测支付逻辑，回调通过gameObject发送
    NSLog(@"checkPay:%@",[NSString stringWithUTF8String:gameObject]);
    [[GameSDKApi shareInstance]checkPay:[NSString stringWithUTF8String:gameObject]];
}

/**
 * 同步用户信息
 */
extern "C" void syncData(const char *dataJson,const char *gameObject){
    //调用sdk的同步用户信息逻辑
    NSLog(@"syncData:%@",[NSString stringWithUTF8String:dataJson]);
    [[GameSDKApi shareInstance] syncData:[NSString stringWithUTF8String:dataJson] gameObject:[NSString stringWithUTF8String:gameObject]];
}

/**
 * 退出游戏
 */
extern "C" void exitGame(){
    //调用sdk的退出app逻辑
    NSLog(@"exitGame");
    [[GameSDKApi shareInstance] exitGame];
}

@end

